package org.pageley.games.sanctuary.view;

import java.util.Collection;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.pageley.games.sanctuary.domain.environment.Environment;
import org.pageley.games.sanctuary.domain.event.Event;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.AbstractController;

public class EndTurnController extends AbstractController {
	
	private Environment environment;

	public void setEnvironment(Environment environment) {
		this.environment = environment;
	}

	public ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception {
		environment.endTurn();
		Collection<Event> events = environment.dequeueEvents();
        ModelAndView mav = new ModelAndView("update");
        mav.addObject("events", events);
        return mav;
    }


}
